<?php

namespace Database\Factories\System;

use App\Models\System\Dict;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\System\Admin>
 */
class DictFactory extends Factory
{
    protected static int $index = 0;

    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        if (self::$index == 0) {
            $maxId = Dict::query()->orderByDesc('id')->first('id');
            self::$index = $maxId?->id ?: 0;
        }
        $index = static::$index++;

        return [
            'title' => '测试字典',
            'code' => 'checktest'.$index,
        ];
    }
}
